package com.example.myapplication;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.preference.DialogPreference;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class MemoRandum extends AppCompatActivity implements AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener {

    ListView lv;
    private List<String> currentData = new ArrayList<String>();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_memo_randum);
        lv = (ListView) findViewById(R.id.lv_memory);
        lv.setOnItemClickListener(this);
        lv.setOnItemLongClickListener(this);
        currentData.add("1");
        currentData.add("2");
        currentData.add("3");
        ArrayAdapter<String> adapter= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,currentData);
        lv.setAdapter(adapter);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }

    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
//        final int id = new currentDataId.get(pos);
//        AlertDialog ad = new AlertDialog.Builder(MemoRandum.this)
//                .setTitle("确定删除此项？")
//                .setMessage("您确定要删除这条备忘吗？")
//                .setPositiveButton("确定",new OnClickListener(){
//            @Override
//            public void onClick(DialogPreference arg0,int arg1){
//                helper.delete(id);
//                loadData();
//            }
//        })
//                .setNegativeButton("取消",new OnClickListener(){
//                    @Override
//                    public void onClick(DialogPreference dialog,int which) {
//
//                    }
//                })
//                .create();
//        ad.show();
        return false;
    }

    public void Creat_Memo(View view) {
        Intent intent = new Intent("android.intent.action.activiry_insert_modify");
        startActivity(intent);
    }
}
